---------------------------------------------------------------
File name   :  vv_ahblite_transaction_h.e
Title       :  Common type declarations
Project     :  vv_ahblite eVC
Developers  :  stefan, filip
Created     :  26.07.2011.
Description :  This file declares master,slave and monitor transactions which will be different kinds of base transaction

Notes       :
---------------------------------------------------------------
Copyright  (c)2011
---------------------------------------------------------------

<'
package vv_ahblite;

-- ==========================================================================
-- Bus transaction. Serves as a base struct to more complex
-- transaction structs.
-- ==========================================================================

type vv_ahblite_transaction_kind_t: [MASTER,SLAVE,MONITOR];

struct vv_ahblite_transaction like any_sequence_item {

    !start_time : time;
    !end_time   : time;

    --master generated signals
    %addr : vv_ahblite_addr_t;
    %write_data: list of byte; -- so that we can drive byte, halfword and a word
    %burst: vv_ahblite_burst_t;
    %lock: bit;
    %protect: uint (bits : 4);  --TO BE ADDED LATER
    %data_size: vv_ahblite_data_size_t;
    %transfer: vv_ahblite_transfer_t;    
    %write_op: bit;
    
    --slave generated signals
    %read_data :list of byte; -- able to deliver Byte,Halfword and a Word
    %ready : bit;
    %response : bit;
    
    
    
    transaction_kind : vv_ahblite_transaction_kind_t;
    
    keep soft lock == 0;
    keep soft protect == 0x3;
    keep soft addr == 0;--by default
    
    keep (data_size == BYTE => write_data.size() == 1);
    keep  (data_size == HALFWORD => write_data.size() == 2);
    keep  (data_size == WORD => write_data.size() == 4);
    keep gen (data_size) before (write_data);
    
    keep  (data_size == BYTE => read_data.size() == 1);
    keep (data_size == HALFWORD => read_data.size() == 2);
    keep (data_size == WORD => read_data.size() == 4);
    keep gen (data_size) before (read_data);
    
    
    event started;
    event ended;

    -- Called when the transaction has started.
    start_transaction() is {
        start_time = sys.time;
        emit started;
    }; 

    -- Called when the transaction has ended.
    end_transaction() is {
        end_time = sys.time;
        emit ended;
    };

    get_address() : vv_ahblite_addr_t is empty;

    get_write_data() : list of byte is empty;

    transaction_str() : string is {
        result = append(", Addr: ",addr,", Data: ",write_op==1?write_data:read_data,", Burst: ",burst,", Data size: ",data_size,", Transfer: ",transfer,", is write: ",write_op, ", Lock: ",lock,", Protect: ",protect);
    };
    
    get_protect() : uint (bits : 4) is empty;
    
    get_burst() : vv_ahblite_burst_t is empty;
    
    get_lock() : bit is empty;
    
    get_data_size() : vv_ahblite_data_size_t is empty;
    
    get_transfer() : vv_ahblite_transfer_t is empty;
    
    get_write_op() : bit is empty;

    get_read_data() : list of byte is empty;
    
    get_ready() : bit is empty;
    
    get_response() : bit is empty;

};

 extend vv_ahblite_transaction {
    when MASTER {
    --code to be added for master transaction
    };
};

 extend vv_ahblite_transaction {
    when SLAVE {
    --code to be added for slave transaction
    	-------------------------------------------new
    	wait_states_num: uint; -- number of wait states to be added  
    	keep wait_states_num in [0..16];
    	keep wait_states_num > 0 => ready == 0;
    	keep wait_states_num > 0 => response == 0;
    	keep wait_states_num == 0 => ready == 1;
    	keep gen (wait_states_num) before (ready, response);
    	-------------------------------------------new
    	
    };
};

 extend vv_ahblite_transaction {
    when MONITOR {
    --code to be added for monitor transaction
    
    !master_name  : vv_ahblite_agent_name_t;
    !slave_name   : vv_ahblite_agent_name_t;

    transaction_str() : string is only {
        result = append("MonitorTransaction.",master_name,"=>",slave_name,": Addr:",addr," ",write_op," Data:",write_op==1?write_data:read_data);};
    
    };
};

'>
